﻿using MongoDB.Bson.Serialization.Attributes;
using System;

namespace Sustainalytics.Entities.RiskRatings
{
    public class Incident
    {
        public Guid CompanyId { get; set; }
        public Guid EventIndicatorId { get; set; }
        public Guid Id { get; set; }
        public DateTime IncidentDate { get; set; }
        public string IncidentId { get; set; }
        public Location Location { get; set; }
        public string MainTag { get; set; }
        public string Name { get; set; }
        public string Source { get; set; }
        public bool IsMain { get; set; }
        public string ExternalUrl { get; set; }
    }

    public class Location
    {
        public string Address { get; set; }
        public double Latitude { get; set; }
        public double Longitude { get; set; }

        public bool Equals(Location b1, Location b2)
        {
            if (b2 == null && b1 == null)
                return true;
            else if (b1 == null | b2 == null)
                return false;
            else if (Math.Abs(b1.Latitude - b2.Latitude)<1e-16 && Math.Abs(b1.Longitude - b2.Longitude)<1e-16)
                return true;
            else
                return false;
        }

        public int GetHashCode(Location bx)
        {
            int hCode = bx.Latitude.GetHashCode() ^ bx.Longitude.GetHashCode();
            return hCode.GetHashCode();
        }
    }
}